An improved beetle antennae search path planning algorithm for vehicles

With the development of society, the application of mobile robots in industry and life is increasingly extensive, and the local path planning of mobile robots in unknown environments is a problem that needs to be solved. Aiming at the problem that the traditional beetle antennae search (BAS) algorithm can easily fall into local optimum and the optimization accuracy is low, we propose an improved beetle antennae search. It introduces a map safety threshold, the addition of virtual target points, and the smoothing of the path. Map safety threshold means extra space with obstacles at all times, improving path reliability by avoiding collisions. Adding virtual target points reduces situations where the vehicle gets stuck in local optima. The B-spline smoothing path reduces the original path’s straight turns to improve the path’s robustness. The effectiveness and superiority of the algorithm are verified by comparing and testing the existing path planning algorithms through simulation in different environments.


Introduction
In recent years, mobile robots have played an essential role in people's daily life. Mobile robots undertake many tasks that people need to complete [1]. Overall, the research field of mobile robots can be divided into the following sections: navigation and localization [2], environment perception and modeling [3], and multi-robot coordination [4]. Robots have strong application prospects in the industrial field and medical services, special explosion-proof, field exploration, deep-sea exploration, household services, and other areas. These fields require robots to have more efficient path planning, and these fields have attracted the attention of many researchers.
Navigation and positioning can generally divide into sub-directions: positioning, environment establishment, and path planning. Among these research directions, the collision-free path planning task of mobile robots is an important direction. The collision-free path planning task can summarize as a collision-free path from the starting point to the target point according to certain criteria in an environment with obstacles. According to the map information, it can divide into global and local path planning. In current daily life of people, mobile robots do not always carry out global path planning in an environment with known obstacles, and most robots use unknown environments in their work tasks. Therefore, local path planning is more practical than global path planning. This paper mainly studies the problem of vehicle local path planning.
In previous studies, researchers mainly considered using different algorithms to solve the path planning problem of mobile robots without collision: for example, the A � algorithm [5,6], RRT algorithm [7,8], Dijkstra algorithm [9,10], and artificial potential field method (APF) [11,12] and so on.
Li proposed an improved Dijkstra algorithm, and the improved algorithm can obtain the shortest distance to the target point. However, when the scale of the grid map is large, the Dijkstra algorithm's search efficiency is slow, and the problem is still not effectively improved [13]. Nie uses the Dijkstra algorithm for initial path planning and then improves the ant colony algorithm (ACO) to optimize the initial path. There are also shortcomings that the local optimum has not completely solved [14]. Zhang and others introduced radar threat function and three-dimensional bidirectional sector-shaped multi-layer variable-step search strategy in the traditional A � algorithm to meet the waypoint accuracy and algorithm search efficiency [15]. Hou uses an improved Q-Learning algorithm combined with artificial potential field path planning to improve planning efficiency [16].
Miao proposed that the angular guiding factor and the obstacle removal factor are introduced into the transition probability of the ACO algorithm [17]. Fu proposed an algorithm combining APF-ACO. The inflection point optimization algorithm is used to reduce the number and length of inflection points in the path, and the curve fitting algorithm is used to optimize the path [18]. Wang combines polynomial curves and artificial algorithms to enable motion planning after vehicle impact and adjust the vehicle's trajectory and yaw motion to achieve obstacle avoidance function [19]. Zhang proposed to generate quadratic programming-based trajectory clustering in the case of invalid driving conditions and assign different timestamps to each waypoint through time sampling [20]. Jiang proposed an intelligent algorithm combining the ant colony algorithm and the BAS algorithm, using ACO to generate the initial path and then the BAS algorithm to orient the search to ensure the stability of its pathfinding [21]. Wu also proposed the Obstacle Avoidance BAS algorithm for robot path planning [22]. The authors mentioned above have made improvements in path planning and path smoothing. However, there are still problems such as easy falling into local optimization, long search time of the algorithm, and poor path smoothing effect.
To solve the above problems, we introduced an improved BAS-based virtual target point algorithm called virtual beetle antennae search (VBAS). We applied the improved algorithm to the path planning problem of vehicles, and the algorithm has a low time complexity while satisfying the safety and collision-free obstacles. The remainder of this paper is organized as follows: in section 2, the problem definition that this paper needs to solve describe in detail. In section 3, the VBAS algorithm, introduces two aspects of algorithm flow and improvement. In section 4 evaluates the performance of its improved VBAS algorithm through simulation and comparison with other algorithms. In section 5, the full text and final outlook summarize. The main contributions of this paper are as follows.
1. The virtual target point adds to the traditional BAS algorithm, and a new intelligent optimization algorithm VBAS proposes, which improves the ability of the vehicle to fall into the local extreme value.
2. The proposed VBAS algorithm can avoid obstacles in the local path planning problem and has the advantage of fast planning.
3. The algorithm's effectiveness verifies in the vehicle application, and the vehicle's superiority in path planning under the requirement of fast obstacle avoidance is proven by comparing it with the existing algorithm.

Problem description
This paper mainly solves the problem of local path planning. Specifically, it is necessary to solve the problem of planning a collision-free path from the starting point to the target point in a static environment with unknown obstacle information. The map is preset, the static obstacles are also present, and the vehicle only detects the obstacle information within the current range. The initial point and the target point are given in advance. This relationship is embodied in a 0-1 matrix as follows.
( where M i,j is the element map, and O is the obstacle area. The proposed algorithm is suitable for the path planning problem with an objective function. The objective function with constraints on the path can generally express Formula 2. where g(�) is the function to be optimized, x2R k the current point coordinate, x tar 2R k the target point coordinate, and k is the dimension of the planning space. For the planned path to be effective, the function to be optimized needs to be as small as possible. The path generated by the algorithm may be very close to the obstacle, and if the path is used directly as a planned path by the vehicle, the vehicle will have a high risk of colliding with the obstacle. Therefore, maintaining an appropriate distance from obstacles must be considered during path planning. In this paper, the concept of a safety threshold is proposed. Since the algorithms in this paper are all based on the beetle antennae algorithm, the initial moving step of the BAS is used as its safety threshold. Fig 1A is a 100×100 pixel map of the simulated environment. The black grid represents the obstacle area, which is 0 in Formula 1, and the rest of the area is a non-obstacle area, which is 1 in Formula 1. Fig 1B shows this paper to construct a global grid map integrated with the safety level, express the distance between obstacles in a https://doi.org/10.1371/journal.pone.0274646.g001 more detailed manner, establish a safety threshold, and solve the problem of nodes approaching obstacles in the vehicle's planned path.
When all the waypoints in the set of waypoints planned by the VBAS algorithm are not in the obstacle area, and within the safety threshold, this planning is considered valid. When this path is directly connected, it is very tortuous, increasing the vehicle's energy consumption and losing its moving speed. Therefore, the generated path needs to be smooth to ensure that it can use for robot movement. While ensuring the feasibility of the path, planning time is also an important attribute. The faster the planning time, the more practical the algorithm is. Based on the description of the above problem, the goal we need to achieve is to plan a smoother collision-free path from the starting point to the goal point for the vehicle as quickly as possible.

VBAS algorithm
The traditional BAS is an algorithm inspired by the foraging principle of beetle antennae search. The main purpose of this paper is to plan a collision-free path from the source point to the target point on the map. The distribution of the objective function is equivalent to the distribution of food smells in the space. The beetle flies in a certain direction according to its perception, and the scent information collected by the antennas is the basis for the next optimization. According to the different scent concentrations of the left and right whiskers, the running trajectory of the next point judges until the current point coincides with the target point and the algorithm iteration ends. At this time, the vehicle finds the maximum point of the global smell, which is the end of the path planning [23,24]. When the antenna touches the obstacle, a virtual target point is added in front of the other side of the antennae to guide the vehicle to avoid the obstacle. When the vehicle coincides with the target point, at the end of its iterative process, at this time, the B-spline method performs to smooth the path, and the processed path set is output. rectangle represents the obstacle area, the η i represents current virtual target point range, and i represents the number of iterations.
The whole algorithm can divide into the following three parts: virtual target point and candidate point generation, virtual target point and candidate point selection, and final path generation.
The rands (.) function is a random generation function and k is the data dimension, representing the planning space's dimension in this paper k = 2. After the direction vector d ! obtains, the coordinates of two candidate points x l 2R k and x r 2R k two virtual target points x vl 2R k , x vr 2R k are generated according to the detection distance Formulas 4 and 5.
where x2R k is the current location, t is the current iteration number, λ is the weight of the virtual target point of VBAS, which changes the size of the environment, and δ t is the beetle antennae search area, which is calculated by the following Formula 6.
Among them η is the attenuation rate of the long beetle detection distance and α is the attenuation increase amount, which adjusts according to the size of the environment. Adjusting η and α can improve the obstacle avoidance ability and the ability to stay away from the local minima of the beetle antennae search algorithm.

Virtual target point selection strategy
This part aims to determine the coordinates of the next path point according to the candidate point selection in Section 3.1 and obtain the coordinates of the two candidate points and the virtual target point according to Formulas 4 and 5. The VBAS algorithm m is suitable for path planning problems with specific target points. This paper sets an objective function f(�):R k !R, which is essentially a function to be optimized. The next waypoint is determined based on the value of the objective function. The function to be optimized is defined below in Formula 7.
where x is the current point coordinate, x tar is the target point, x obs is the obstacle with the closest d-direction vector distance to the current vehicle, and c is the safety threshold. When the virtual point is smaller than the obstacle threshold, switch to the function to be optimized. In this paper, the smaller the objective function value is, the closer the target function is to the target point, so the purpose is to minimize the objective function. However, if the objective function is minimized throughout the process, it may cause the vehicle to be unable to avoid obstacles. The whole objective optimization function process can divide into two states, and one is in the search process in which the virtual objective point does not touch the obstacle temporarily. The other is the search process in which the virtual target point touches the obstacle. The corresponding candidate, and point selection strategies will also be different. When the virtual target point does not touch the obstacle, the corresponding target point is the path target point. When one side of the antenna touches the obstacle, the virtual target point of the beetle on the other side will work to guide the candidate point to move towards the virtual target point. If there are no collision obstacles on both antennas, the target point switches to the path target point. This paper introduces a virtual target point, and the relevant formulas for generating the next coordinate point are as follows to realize the two-state switching. where the sign(�) is the symbolic function.

Judging the shock process
Since the virtual target point is close to the current position, the path oscillation problem will inevitably occur. This paper proposes to judge whether the current path set oscillates and how to remove the path set oscillation. When the average Euclidean distance between the current position and the first n points in the path set is less than the threshold, it considers that an oscillation phenomenon occurs in the path set. The path from the first n points to the current position is deleted.
where Q g represents the g points, the g is adjusted according to the map size in this paper g = 15, and mean represents the average value.

Path smoothing optimization
This part aims to generate a collision-free smooth path for the vehicle. Since the waypoints have been obtained in Sections 3.1 and 3.2, this part directly connects the various waypoints.
The path needs to be smooth because the directly connected path points are too tortuous. Schoenberg proposed the B-spline method in 1946. In path planning, the B-spline method is a commonly used path smoothing [22,25,26]. The B-spline method has the following characteristics: The B-spline curve contains the convex polygon of its control polyline. Because of this characteristic, the B-spline method can modify the effect of a local path without changing the shape of the entire path. The formula of the B-spline curve method is as follows: where n is the number of control points, C i is the coordinate of the control point, and B i,p (u) is the spline basis function of the control point C i . Fig 3 shows the smooth path process. Fig 3 shows the four control points C i , C i+1 , C i+2 , C i+3 and the smooth inflection point n i , the adjacent coordinates, and three points are the center points of the three adjacent key inflection points, which are iteratively solved by Formulas 12 and 13.
where u is the knot node, the number of which is N, determined by order of the spline function d = 3 and the number of control points n. In this paper, to ensure that the smooth curve is more in line with the constraints of the kinematics and dynamics of the vehicle, the order of the sampling bar function d = 3 and the number of control points n = 4, and the set of knots node sequence U = [u 0 ,u 1 ,u 2 ,u 3 ,u 4 ,u 5 ,u 6 ] control points can be obtained.
Finally, through the control point C i corresponding to the spline basis function B i,d (u), the B-Spline can be obtained as:

Algorithm simulation and comparison
The algorithm proposed in this paper is suitable for path planning problems with objective functions. This section aims to compare and verify the effectiveness of the VBAS algorithm through a series of simulations and comparisons with other algorithms. The following algorithms verify the algorithm's effectiveness by averaging the results of multiple simulations. Think of the vehicle as a particle. In Section 4.1, four simulation results are selected for indepth analysis, proving the robustness and generality of the VBAS algorithm. In Section 4.2, the VBAS algorithm compares with other algorithms. By comparison, the superiority of the algorithm is proven.
All simulations in this paper are implemented on MATLAB and use the same parameters. The size of the simulated map is 450×450 pixels. On this map, the final parameters take the following values: the step size is 0.5. The initial radius of the beetle is 0.5. The initial radius of the virtual target point is 1. The step size decay rate η = 0.95, the step size decay increment α = 0.005, the decay rate, decay increment and step value of the beetle and the virtual target point are the same. The weight of the virtual target point of the beetle λ = 5.

Illustrative examples
The purpose of this section is to verify the effectiveness of the VBAS algorithm through multiple simulation results. The simulation maps shown in this section can divide into single and multiple obstacles, according to the number of obstacles. They divide into regular obstacles according to their type and irregular obstacles. This paper presents the simulation results using single and multiple obstacles.     Table 1 is the statistics of the above four simulation results. P represents the path length, and n is the number of iterations. Each of the above simulations was run 100 times with the same parameters, and the average running time was obtained to evaluate the VBAS algorithm. In Fig 5A, when the current point is close to the obstacle, the oscillation is obvious, which is caused by the switching between the virtual target point and the target point. After the path generates, the path oscillation judgment will perform. If the oscillation exceeds the threshold, it will delete the current path subset. The steep drop of the function curve in Fig 5B is because of the target point switch, and the target function drops sharply when the target point switch

Comparison
This section conducts extensive comparisons with existing algorithms to further demonstrate the superiority of the VBAS algorithm proposed in this paper. To verify the algorithm's effectiveness in many aspects, we simply compare the VBAS algorithm with other algorithms. Running time and path length are compared as evaluation metrics. The running time reflects the real-time nature of the algorithm. The shorter the runtime, the more likely it is to achieve realtime path planning. On the premise of successful obstacle avoidance, the path length is as short as possible. The overall comparison results are shown in Table 2. It can be seen from Table 2 that the VBAS algorithm generally performs in terms of path length but has obvious advantages in running time.

Comparison of APF algorithms.
To further verify the effectiveness of the VBAS algorithm, this paper selects another commonly used static path planning APF algorithm to study the path planning algorithm. The two algorithms were simulated multiple times on each  map under the same operating environment to avoid chance, and the results are reported in Table 2. It can be seen from the results that although the path length obtained by VBAS is not better than that of APF, it has obvious advantages in time.

Conclusion
This paper proposes an improved VBAS intelligent optimization algorithm based on the BAS algorithm. To verify the algorithm's effectiveness, it applies to the path planning of vehicles. The specific case is to plan a collision-free and smooth path in a static environment under the premise of giving starting and target points. In addition, simulation results provide to verify the method's effectiveness. In future work, the three-dimensional dynamic environment can replace the two-dimensional static environment, and the path planning research of the dynamic obstacle environment can be carried out in the 3D environment.